public class ZhaiZhiJie2
{
    public static void main(String[] args) {
        String str1 = "want you to know one thing";
        char[] str2 = str1.toCharArray();
        check(str2);
    }
    public static void check(char[] str2)
    {
        int countN = 0;
        int countO = 0;
        for(int i = 0; i < str2.length; i++)
        {
            if(str2[i] == 'n')
                countN++;
            else if(str2[i] == 'o')
                countO++;
        }
        print(countN,countO);
    }

    public static void print(int countN, int countO)
    {
        System.out.println("字母n和o出现的次数分别为：" + countN + "、" + countO);
    }
}
